package ran.entity;

import lombok.Data;
import ran.enums.ResultCode;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ran
 * Date: 2025-10-16
 * Time: 17:26
 */
@Data
public class TableDataInfo {
    private long total; // 数据总条数
    private List<?> rows;
    private int code;
    private String msg;

    public static TableDataInfo empty() {
        TableDataInfo tableDataInfo = new TableDataInfo();
        tableDataInfo.setCode(ResultCode.SUCCESS.getCode());
        tableDataInfo.setRows(new ArrayList<>());
        tableDataInfo.setMsg(ResultCode.SUCCESS.getMsg());
        tableDataInfo.setTotal(0);
        return tableDataInfo;
    }
    public static TableDataInfo success(List<?> list, long total) {
        TableDataInfo tableDataInfo = new TableDataInfo();
        tableDataInfo.setCode(ResultCode.SUCCESS.getCode());
        tableDataInfo.setRows(list);
        tableDataInfo.setMsg(ResultCode.SUCCESS.getMsg());
        tableDataInfo.setTotal(total);
        return tableDataInfo;
    }
}
